<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="/WEB-INF/tld/app.tld" %>
<%@ taglib prefix="ct" uri="/WEB-INF/tld/commonTag.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> 
<%@ include file="/WEB-INF/jsp/common/common_header.jsp" %>
<%@ include file="/WEB-INF/jsp/common/common.jsp" %>


<script language="javascript">
    

	function funcDetail(transDate,cardComCd) {
		width = 830;
		height = 750;
		var user_id = $("#user_id").val();
	    x = (screen.width) ? (screen.width-width)/2 : 0;
	    y = (screen.height) ? (screen.height-height)/2 : 0;
	    var popUrl = 'popCardWithDrawDetailInfo.do?transDate='+transDate+'&cardComCd='+cardComCd+'&user_id='+user_id;
	    var win =window.open(popUrl,'popCardWithDrawDetailInfo', 'left=' + x + ',top=' + y + ',width=' + width + ',height=' + height + ',scrollbars=yes,status=no,menubar=no');
	    win.focus();
	}

    
	function funChangeData(transDate,cardComCd,userId){
		
		var reqDate = $("input[name=changeDate]").val();
		var strStatus =reqDate+" 날짜로 입금예정일을 바꾸시겠습니까?";
		if (!confirm(strStatus)) {
			return;
		}			
		
		
        var url = "ajaxChangeData.do";   

        $.ajax({
            type : "POST",
            url : url,
            async : true,
            dataType : "json",
            data : {
            	 reqDate : reqDate
            	,transDate : transDate
            	,cardComCd : cardComCd
            	,userId : userId
            },
            success : function(data) {
            	if(data == 'success'){
            		alert(reqDate+" 날짜로 입금예정일 변경 성공");
            		location.reload(); 
            	}else{
            		alert("입금예정일 변경 실패");
            	}
            },
            error : function(data) {
                alert("통신에러 입니다. 관리자에게 문의 바랍니다.");
               
            }
        }); 
		
	}	    
    //////////////////////////////////
    //jQuery datepicker Form set
    ///////////////////////////////// 
    $(function() {
        $("#changeDate").koreadate();
    });    

        
    </script>
</head>
<body>
<div class="con_area" style="width: 900px">
<form id="form" name="form" action="" >
<input type="hidden" id="user_id" name="user_id" value="${model.user_id}"/>
<br>
<br>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td align="left"><h2 class="tit">카드사별 승인내역 상세조회 </h2></td>
        <% if (rightCd.equals("01")){ %>
        <c:if test='${model.cardComCd != "00"}'>    
	        <td aling="right"><h2 class="tit">입금예정일 변경:&nbsp;&nbsp; </h2>
	        		<input type='text' id="changeDate" name="changeDate" value="${model.transDate}" title="YYYY-MM-DD" style="width: 100px;" maxlength="10" readonly/>
		           &nbsp;&nbsp;
		            <input type="button" class="button_28_02" value="변경" style="width:65px;" onclick="funChangeData('${model.transDate}','${model.cardComCd}','${model.user_id}');" />
	        </td>
        </c:if>
        <%} %>
    </tr>
</table>
 <div style="margin-top:7px"/>
    <table cellpadding="0" cellspacing="1" border="0" class="data_table_01" style="width:100%;" >
    <colgroup>
        <col width="3%" />
        <col width="12%" />
        <col width="8%" />
        <col width="5%" />
        <col width="8%" />
        <col width="14%" />
        <col width="10%" />
        <col width="10%" />
        <col width="9%" />
        <col width="12%" />
        <col width="9%" />

    </colgroup>
    
    <thead>
        <tr>
            <td class=data_01 style= 'text-align:center;'>번호</td>
            <td class=data_01 style= 'text-align:center;'>승인일</td>
            <td class=data_01 style= 'text-align:center;'>승인시간</td>
            <td class=data_01 style= 'text-align:center;'>구분</td>
            <td class=data_01 style= 'text-align:center;'>카드사</td>
            <td class=data_01 style= 'text-align:center;'>카드번호</td>
            <td class=data_01 style= 'text-align:center;'>승인번호</td>
            <td class=data_01 style= 'text-align:center;'>승인금액</td>
            <td class=data_01 style= 'text-align:center;'>카드사<br>입금예정액</td>
            <td class=data_01 style= 'text-align:center;'>입금예정일</td>
            <td class=data_01 style= 'text-align:center;'>원거래<br>(취소)일</td>

        </tr>
    </thead>
    <tbody>
<c:if test='${empty cardWithDrawDetailInfo}'>    
    <tr>
        <td colspan="10" align =center>
            <span style="padding-top:3px;*padding-top:2px;"><strong>조회된 데이터가 존재하지 않습니다.</strong></span>
        </td>
    </tr>
</c:if>
<c:set var="rnum" value="0"/>
<c:set var="prodAmtTot" value="0"/>
<c:set var="expectProdAmtTot" value="0"/>
<c:if test='${not empty cardWithDrawDetailInfo}'>
	<c:forEach var="vo" items="${cardWithDrawDetailInfo}">
<c:set var="rnum" value="${rnum +1}"/>	

<c:choose>
    <c:when test="${vo.okFlag eq 00}">
		<c:set var="prodAmtTot" value="${prodAmtTot +vo.prodAmt}"/>
		<c:set var="expectProdAmtTot" value="${expectProdAmtTot + vo.expectProdAmt}"/>	
		       
    </c:when>
    <c:otherwise>
        <c:set var="prodAmtTot" value="${prodAmtTot -vo.prodAmt}"/>
		<c:set var="expectProdAmtTot" value="${expectProdAmtTot - vo.expectProdAmt}"/>        
    </c:otherwise>
</c:choose>	  

	    <tr  <c:if test='${vo.okFlag eq 00}'> onMouseOver="this.style.background='#FFF9E1'" onMouseOut="this.style.background='#FFFFFF'"  </c:if> <c:if test='${vo.okFlag eq 99}'> BGCOLOR="#CCCC99" </c:if> height ="8">
	        <td style="text-align:center;">${rnum}</td>
	        <td style="text-align:center;">${vo.transDate}<ct:getDay day="${vo.transWeekDay}"/></td>
	        <td style="text-align:center;">${vo.transTime}</td>
	        <td style="text-align:center;">
									<c:choose>
									    <c:when test="${vo.okFlag eq 00}">
									       승인
									    </c:when>
									    <c:otherwise>
									        <font color="red">취소</font>
									    </c:otherwise>
									</c:choose>	        
	        </td>
	        <td style="text-align:center;">${vo.cardComCd}</td>
	        <td style="text-align:center;">${vo.cardNum}</td>
	        <td style="text-align:center;">${vo.okNum}</td>
	        <td style="text-align:center;"><fmt:formatNumber value="${vo.prodAmt}" pattern="#,###" /></td>
	        <td style="text-align:center;"><fmt:formatNumber value="${vo.expectProdAmt}" pattern="#,###" /></td>
	        <td style="text-align:center;">${vo.expectTransDate}<ct:getDay day="${vo.expectTransWeekDay}"/></td>
	        <td style="text-align:center;">${vo.cancelDate}</td>
	    </tr>
    </c:forEach>
</c:if>
	    <tr onMouseOver="this.style.background='#FFF9E1'" onMouseOut="this.style.background='#FFFFFF'" height ="30px">
	    <c:if test='${not empty cardWithDrawDetailInfo}'>    
	    	<td colspan="7" align =center>합계</td>
	    </c:if>
	    <c:if test='${empty cardWithDrawDetailInfo}'>
	    	<td class=data_01 style= 'text-align:center;' colspan="7" >합계</td>
	    </c:if>
	        
	        <td style="text-align:center;"><font color=blue><fmt:formatNumber value="${prodAmtTot}" pattern="#,###" /></font></td>
	        <td style="text-align:center;"><font color=blue><fmt:formatNumber value="${expectProdAmtTot}" pattern="#,###" /></font></td>
	        <td tyle="text-align:center;"></td>
	        <td tyle="text-align:center;"></td>
	    </tr>
    </tbody>
    </table>
    <br>

</form>
</div>
</body>

